import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Reader;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.apache.i18n.translater.PowerTranslater;
import org.apache.i18n.translater.Translater;
import org.apache.i18n.translater.TranslaterFactory;




public class TranslateTomcatByHand {
	public static void main(String[] args) {

		

	    	String path="java.javax.el";	 
		    path="java.javax.servlet";
		    path="java.javax.servlet.http";
		    
		    path="java.org.apache.catalina.authenticator";  //16
		    path="java.org.apache.catalina.connector";  //42
		    path="java.org.apache.catalina.core"; //205
		    path="java.org.apache.catalina.ha"; //1
		    path="java.org.apache.catalina.loader"; //53
		    path="java.org.apache.catalina.manager"; //95
		    path="java.org.apache.catalina.mbeans"; //5
		    path="java.org.apache.catalina.realm"; //77
		    
		    path="java.org.apache.catalina.security"; //1
		    path="java.org.apache.catalina.servlets"; //19
		    path="java.org.apache.catalina.session"; //68
		    path="java.org.apache.catalina.startup"; //86
		    
		    path="java.org.apache.catalina.tribes"; //1
		    path="java.org.apache.catalina.users"; //7
		    
		    path="java.org.apache.catalina.util"; //9
		    path="java.org.apache.catalina.valves"; //68
		    
		    
		    path="java.org.apache.coyote.ajp"; //24
		    path="java.org.apache.coyote.http11";//31
		    
		    path="java.org.apache.jasper.resources";//372
		    
		    path="java.org.apache.naming";//13
		    path="java.org.apache.naming.resources";//21
		    
		    path="java.org.apache.tomcat.util.buf.res";//3
		    path="java.org.apache.tomcat.util.http.res";//45
		    path="java.org.apache.tomcat.util.net.jsse.res";//2
		    path="java.org.apache.tomcat.util.net.res";//24
		    path="java.org.apache.tomcat.util.threads.res";//3
		    
		    
		    path="java.org.apache.catalina.manager.host";
			autoTranslate(path);

		
	}

	private static void autoTranslate(String path) {
    	path=StringUtils.replaceChars(path, ".", "/");
		String tomcatDir="../tomcat-zh";	
		
		Translater createTranslater = TranslaterFactory.createTranslater(Translater.GOOGLE);
		
		PowerTranslater translater=new PowerTranslater(createTranslater);
		
		File fromFile = new File(tomcatDir+"/src/"+path+"/LocalStrings.properties");
		File toFile = new File(tomcatDir+"/src/"+path+"/LocalStrings_zh.properties");

		
		System.out.println(fromFile);
		translater.doPropertiesFile(fromFile, toFile, Apache.ASL);
	}
	

}
